package com.test.langchain4j.controller;

import cn.hutool.core.date.DateUtil;
import com.test.langchain4j.service.FunctionAssistant;
import com.test.langchain4j.service.WeatherAssistant;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @description:
 * @author: liuziyang
 * @since: 2025/8/1 18:51
 * @modifiedBy:
 * @version: 1.0
 */
@RestController
@Slf4j
public class ChatFunctionCallingController {
  @Resource private FunctionAssistant functionAssistant;
  @Resource private WeatherAssistant weatherAssistant;

  /**
   * http://localhost:9011/chatfunction/test1
   *
   * @return the string
   */
  @GetMapping(value = "/chatfunction/test1")
  public String test1() {
    String chat = functionAssistant.chat("开张发票,公司：尚硅谷教育科技有限公司 税号：atguigu533 金额：668.12");

    System.out.println(chat);

    return "success : " + DateUtil.now() + "\t" + chat;
  }

  /**
   * http://localhost:9011/chatfunction/test2
   *
   * @param cityCode the city code
   * @return the string
   */
  @GetMapping(value = "/chatfunction/test2")
  public String test2(@RequestParam(defaultValue = "101010100") String cityCode) {
    String chat = weatherAssistant.chat(cityCode);
    System.out.println(chat);
    return "success : " + DateUtil.now() + "\t" + chat;
  }
}
